Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent unhandled promises in createAsyncThunk #570

Merged

Conversation

msutkowski
Copy link
Member

@msutkowski msutkowski commented May 20, 2020

Note: There is currently not a good way to test that unhandledRejection errors happen or not. This PR introduces a method that will 'crash' the test runner if you happen to forget to resolve a promise.

Things tried before going to the 'crash the test runner' route:

  • using process.on('unhandledRejection', {}) to use a callback function, and check that it is fired.
  • logging in various ways and test with getLog().

After some research, it seems that jest doesn't handle process.on in the test file itself, which is why it's moved into the config. See: jestjs/jest#5620

@netlify
Copy link

netlify bot commented May 20, 2020

Deploy preview for redux-starter-kit-docs ready!

Built with commit 087b606

https://deploy-preview-570--redux-starter-kit-docs.netlify.app

@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 087b606:

Sandbox Source
busy-dewdney-v0f6v Configuration
heuristic-mayer-nk1ry Configuration
eloquent-chatterjee-0mfmh Configuration

@msutkowski msutkowski marked this pull request as ready for review May 20, 2020 19:49
@msutkowski msutkowski changed the title Throw when promises are unhandled in createAsyncThunk Prevent unhandled promises in createAsyncThunk May 20, 2020
Copy link
Member

@phryneas phryneas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@markerikson markerikson merged commit af88149 into reduxjs:master Jun 13, 2020
@msutkowski msutkowski deleted the fix/createAsyncThunk-catch-aborted branch June 13, 2020 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Abort createAsyncThunk Uncaught (in promise)
3 participants